$(function(){

function callShop() {
			api.call({
				type : 'tel_prompt',
				number : '111111'
			});
		}

		var myChart = echarts.init(document.getElementById('maina'));
		function randomData() {
			now = new Date(+now + oneDay);
			value = value + Math.random() * 21 - 10;
			return {
				name : now.toString(),
				value : [[now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-'), Math.round(value)]
			}
		}

		var data = [];
		var now = +new Date(1997, 10, 2);
		var oneDay = 24 * 3600 * 1000;
		var value = Math.random() * 1000;
		for (var i = 0; i < 1000; i++) {
			data.push(randomData());
		}
		option = {
			/* 	title:{
			 text:'云币：999.89   消费金：888.98',
			 left:'center',
			 backgroundColor:'rgba(128, 128, 128, 0.5)'
			 },
			 */
			tooltip : {
				trigger : 'axis',
				formatter : function(params) {
					params = params[0];
					var date = new Date(params.name);
					return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
				},
				axisPointer : {
					animation : false
				}
			},
			xAxis : {
				type : 'time',
				splitLine : {
					show : false
				}
			},
			yAxis : {
				type : 'value',
				boundaryGap : [0, '100%'],
				splitLine : {
					show : false
				}
			},
			series : [{
				name : '模拟数据',
				type : 'line',
				showSymbol : false,
				hoverAnimation : false,
				data : data,
			}]
		};
		timeTicket = setInterval(function() {
			data.push(randomData());
			myChart.setOption(option);
		}, 1000);
    
    function asd() {
		var flag = confirm("当前价格为 "+random()+"，确认购买么？");
			if (flag == true) {
			alert("买入成功！");
			} else {
		           }
		 }
		
		function random(){
		var result = getconfirmdata();
		for (var i = 0; i < result.length; i++) {
		return result[i];
		}
		};
		function getconfirmdata(){
		var dataAll = [];
		var url = "http://192.168.253.6:8058/user/getalldata";
		ajaxJsonP(url, function (data) {
		for (var i = 0; i < data.length; i++) {
		dataAll[i] =data[i].LoginName;
		}
		});
		return dataAll;
		}
		function ajaxJsonP(url,callbackfun){
		$.ajax({
		type: "get",
		url: url,
		dataType: "jsonp",
		jsonp: "callback",
		jsonptype:"success_jsonp",
		success: function (data) {
		if (data) {
		callbackfun(data);
		}
		}
		});
}
